﻿using Messhall.Framework.Domain.DomainObject;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Messhall.Domain.Permission.BusinessObjects
{
    public class RoleEntity : EntityBoBase
    {
        #region 成员变量

        /// <summary>
        /// 父级角色
        /// </summary>
        public Guid ParentId { get; set; }

        /// <summary>
        /// 角色名称
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// Code代码
        /// </summary>
        public string Code { get; set; }

        /// <summary>
        /// 备注信息
        /// </summary>
        public string Remark { get; set; }

        #endregion
    }

    public class Role : BoBase, IAggregateRoot
    {
        private RoleEntity SelfEntity
        {
            get { return Entity as RoleEntity; }
            set { this.Entity = value; }
        }

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="entity"></param>
        public Role(Guid parentId, string name, string code, string remark)
        {
            this.SelfEntity = new RoleEntity()
            {
                Name = name,
                ParentId = parentId,
                Code = code,
                Remark = remark,
            };
        }

        public Role(RoleEntity entity)
        {
            this.SelfEntity = entity;
        }

        private List<RolePermission> RolePermissions { get;  set; }

        public string GetName()
        {
            return this.SelfEntity.Name;
        }

        public void SetName(string name)
        {
            this.SelfEntity.Name = name;
        }

        public Guid GetParentId()
        {
            return this.SelfEntity.ParentId;
        }

        public void SetParentId(Guid parentId)
        {
            this.SelfEntity.ParentId = parentId;
        }

        public string GetCode()
        {
            return this.SelfEntity.Code;
        }

        public void SetCode(string code)
        {
            this.SelfEntity.Code = code;
        }

        public string GetRemark()
        {
            return this.SelfEntity.Remark;
        }

        public void SetRemark(string remark)
        {
            this.SelfEntity.Remark = remark;
        }

        public void SetPermission(Guid permissionsKeyId)
        {
            
        }

        public void RemoveRole(Guid permissionsKeyId)
        {
            
        }
    }
}